package com.fishingwithme.infrastructure.dtos;

import com.fishingwithme.domain.common.Location;
import cn.fishingwithme.domain.spots.*;
import com.fishingwithme.domain.spots.*;
import com.fishingwithme.infrastructure.utils.CommonUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.Data;

import java.util.List;

@Data
public class SpotEnhanceDto {
    private Long id;
    private String cityCode;
    private String city;

    @JsonIgnore
    private Double longitude;
    @JsonIgnore
    private Double latitude;
    private Location location;

    private List<String> pics;

        private List<ObjectNode> jsonSpotTypes;
        private List<ObjectNode> jsonFishTypes;

    private String name;
    private List<Location> points;
    @JsonIgnore
    private String navLine;
    private Boolean isFree;
    private WaterType waterType;
    private SpotLvl lvl;
    @JsonIgnore
    private String spotTypes;
    @JsonIgnore
    private String fishTypes;

    private Boolean isParkingConvenient;
    private ParkingDistance distance;

    @JsonIgnore
    private String pictures;

    private Boolean isPrivate;
    private Boolean isForbidden;
    private String description;

    public static SpotEnhanceDto format(SpotEnhanceDto dto) {
        dto.setLocation(new Location(dto.getLatitude(), dto.getLongitude()));
        dto.setPics(CommonUtils.convert(dto.getPictures(), String.class));
        dto.setJsonSpotTypes(CommonUtils.convert(dto.getSpotTypes(), SpotType.class));
        dto.setPoints(CommonUtils.convert(dto.getNavLine(), Location.class));
        dto.setJsonFishTypes(CommonUtils.convert(dto.getFishTypes(), FishType.class));
        return dto;
    }
}
